package com.pluszg.nutrition.common.resp;

import com.pluszg.nutrition.common.req.PageBean;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
@ToString
@NoArgsConstructor
public class PageResponse<T> extends PageBean implements Serializable {

    /**
     * 总页数
     */
    private int totalPage;

    /**
     * 数据库的总记录数
     */
    private long totalRecord;

    /**
     * 返回的结果
     */
    private List<T> resultList = new ArrayList<>();

    private Object staticInfo;

    public PageResponse(PageResponse response, List<T> resultList) {
        this(response.getPageNumber(), response.getPageSize(), response.getTotalPage(), response.getTotalRecord(), resultList);
    }

    public PageResponse(PageBean pageBean) {
        super(pageBean.getPageNumber(), pageBean.getPageSize());
    }

    public PageResponse(int pageNumber, int pageSize, int totalPage, long totalRecord, List<T> resultList) {
        super(pageNumber, pageSize);
        this.totalPage = totalPage;
        this.totalRecord = totalRecord;
        this.resultList = resultList;
    }
}
